import 'package:flutter/material.dart';

import 'package:data_table_2/data_table_2.dart';

const primaryColor = Color(0xFF2697FF);
const secondaryColor = Color(0xFF2A2D3E);
const bgColor = Color(0xFF212332);

const defaultPadding = 16.0;

class DataTable2Demo extends StatefulWidget {
  const DataTable2Demo({Key? key}) : super(key: key);

  @override
  State<DataTable2Demo> createState() => _DataTable2DemoState();
}

class _DataTable2DemoState extends State<DataTable2Demo> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(defaultPadding),
      decoration: BoxDecoration(
        color: secondaryColor,
        borderRadius: const BorderRadius.all(Radius.circular(0)),
      ),
      child: DataTable2(
        // dataRowColor: MaterialStateProperty.all(Colors.white),
        columnSpacing: 12,
        horizontalMargin: 12,
        minWidth: 600,
        columns: [
          DataColumn2(label: Text('Column A'), size: ColumnSize.L),
          DataColumn(label: Text('Column B')),
          DataColumn(label: Text('Column C')),
          DataColumn(label: Text('Column D')),
          DataColumn(label: Text('Column NUMBERS'), numeric: true),
        ],
        rows: List<DataRow>.generate(
          100,
          (index) => DataRow(
            cells: [
              DataCell(Text('A' * (10 - index % 10))),
              DataCell(Text('B' * (10 - (index + 5) % 10))),
              DataCell(Text('C' * (15 - (index + 5) % 10))),
              DataCell(Text('D' * (15 - (index + 10) % 10))),
              DataCell(Text(((index + 0.1) * 25.4).toString()))
            ],
          ),
        ),
      ),
    );
  }
}
